package com.ck.daoImpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.ck.dao.AdminDAO;
import com.ck.domain.Admin;
import com.ck.domain.Teacher;

public class AdminDAOImpl extends SqlMapClientDaoSupport implements AdminDAO {

	public List<Admin> getAllAdmin(){
		return (List<Admin>)getSqlMapClientTemplate().queryForList("getAllAdmin");
	}
	
	public Admin getAdminByUsername(String username) {
		return (Admin) getSqlMapClientTemplate().queryForObject("getAdminByUsername",username);
	}

	public Admin getAdminById(Integer id) {
		return (Admin) getSqlMapClientTemplate().queryForObject("getAdminById",id);
	}

	public void addNewAdmin(Admin admin) {
		getSqlMapClientTemplate().insert("addNewAdmin", admin);
	}
	
	public void deleteAdminById(Integer id){
		getSqlMapClientTemplate().delete("deleteAdminById", id);
	}
	
	public void updateAdminOwnInfo(Admin admin) {
		getSqlMapClientTemplate().update("updateAdminOwnInfo", admin);
	}

	public void updateAdminLastLoginTime(Admin admin) {
		getSqlMapClientTemplate().update("updateAdminLastLoginTime", admin);
	}

	public void updateAdminOwnPassword(Admin admin) {
		getSqlMapClientTemplate().update("updateAdminPassword", admin);
	}

	public void updateAdminInfo(Admin admin) {
		getSqlMapClientTemplate().update("updateAdminInfo", admin);
	}

	public void updateAdminPassword(Admin admin) {
		getSqlMapClientTemplate().update("updateAdminPassword", admin);
	}

	public List<Teacher> getAllTeacher(){
		return (List<Teacher>)getSqlMapClientTemplate().queryForList("getAllTeacher");
	}
	
	public Teacher getTeacherById(Integer id){
		return (Teacher) getSqlMapClientTemplate().queryForObject("getTeacherById",id);
	}
	
	public Teacher getTeacherByUsername(String username) {
		return (Teacher) getSqlMapClientTemplate().queryForObject("getTeacherByUsername",username);
	}
	
	public void addNewTeacher(Teacher teacher) {
		getSqlMapClientTemplate().insert("addNewTeacher", teacher);
	}

	public void deleteTeacherById(Integer id) {
		getSqlMapClientTemplate().delete("deleteTeacherById", id);
	}

	public void updateTeacherInfo(Teacher teacher) {
		getSqlMapClientTemplate().update("updateTeacherInfo", teacher);
	}

	public void updateTeacherPassword(Teacher teacher) {
		getSqlMapClientTemplate().update("updateTeacherPassword", teacher);
	}

	

}
